﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Wpf.Windows
{
    /// <summary>
    /// PanelWindow.xaml 的交互逻辑
    /// </summary>
    public partial class PanelWindow : Window
    {
        public PanelWindow()
        {
            InitializeComponent();
            this.Loaded += PanelWindow_Loaded;
        }

        private void PanelWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var stackPanel = new StackPanel()
            {
                Margin = new Thickness(10),
                Background = Brushes.Red,
            };
            var wrapPanel = new WrapPanel()
            {
                Margin = new Thickness(10),
                Background = Brushes.OrangeRed,
            };

            var dockPanel = new WrapPanel()
            {
                Margin = new Thickness(10),
                Background = Brushes.MediumVioletRed,
            };

            this.mygrid.Children.Add(stackPanel);
            this.mygrid.Children.Add(wrapPanel);
            this.mygrid.Children.Add(dockPanel);

            Grid.SetRow(stackPanel, 2);
            Grid.SetRow(wrapPanel, 2);
            Grid.SetRow(dockPanel, 2);

            Grid.SetColumn(stackPanel, 0);
            Grid.SetColumn(wrapPanel, 1);
            Grid.SetColumn(dockPanel, 2);
            var lis = new List<Panel>() 
            { 
                stackPanel, wrapPanel, dockPanel 
            };
            lis.ForEach(p =>
            {
                for (int i = 0; i < 8; i++)
                {
                    var btn = new Button()
                    {
                        Content = "0x" + i.ToString(),
                        Width=60,
                        Height=40,
                    };
                    p.Children.Add(btn);
                }
            });

        }
    }
}
